<template>
  <div>
    <h2>message</h2>
    <p v-if="$fetchState.pending">
      Fetching mountains...
    </p>
    <p v-else-if="$fetchState.error">
      An error occurred :(
    </p>
    <ul>
      <template v-for="item in messageList">
        <li :key="item">
          {{ item }}
        </li>
      </template>
    </ul>
    <button @click="testCookie">
      testCookie
    </button>
  </div>
</template>

<script>
export default {
  // 路由认证参数
  auth: true,
  async fetch () {
    const result = await this.$axios.get('/v1/message/getMessageList')
    if (result && result.data.code == 200) {
      this.messageList = result.data.result
    }
  },
  data () {
    return {
      messageList: []
    }
  },
  methods: {
    async testCookie () {
      const result = await this.$axios.post('/v1/message/test')
      console.log('result is', result.data)
    }
  }
}
</script>

<style>
</style>
